<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>go[2]-数据结构 | Abel&#39;Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="参考golang手册，记录数据类型相关资料；方便日后来回顾基础知识。  基本数据 布尔 整型&#x2F;浮点数 整数 浮点类型   String const   复合数据类型 数组 slice map 结构体    基本数据布尔布尔类型，表示真与假。true|false 整型&#x2F;浮点数数值类型，分为整形和浮点类型，下面列举的是类型，以及读数的区间。 123456789101112uint8       the">
<meta property="og:type" content="article">
<meta property="og:title" content="go[2]-数据结构">
<meta property="og:url" content="http://example.com/2021/07/28/2020/2020-11-03-go[2]-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B/index.html">
<meta property="og:site_name" content="Abel&#39;Blog">
<meta property="og:description" content="参考golang手册，记录数据类型相关资料；方便日后来回顾基础知识。  基本数据 布尔 整型&#x2F;浮点数 整数 浮点类型   String const   复合数据类型 数组 slice map 结构体    基本数据布尔布尔类型，表示真与假。true|false 整型&#x2F;浮点数数值类型，分为整形和浮点类型，下面列举的是类型，以及读数的区间。 123456789101112uint8       the">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2021-07-28T03:33:01.198Z">
<meta property="article:modified_time" content="2021-07-20T12:29:15.533Z">
<meta property="article:author" content="Abel Sean">
<meta property="article:tag" content="golang">
<meta property="article:tag" content="type">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="Abel&#39;Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/css/style.css">

<meta name="generator" content="Hexo 5.4.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Abel&#39;Blog</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://example.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-2020/2020-11-03-go[2]-数据类型" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/07/28/2020/2020-11-03-go%5B2%5D-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B/" class="article-date">
  <time datetime="2021-07-28T03:33:01.198Z" itemprop="datePublished">2021-07-28</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      go[2]-数据结构
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>参考golang手册，记录数据类型相关资料；方便日后来回顾基础知识。</p>
<ul>
<li><a href="#%E5%9F%BA%E6%9C%AC%E6%95%B0%E6%8D%AE">基本数据</a><ul>
<li><a href="#%E5%B8%83%E5%B0%94">布尔</a></li>
<li><a href="#%E6%95%B4%E5%9E%8B%E6%B5%AE%E7%82%B9%E6%95%B0">整型/浮点数</a><ul>
<li><a href="#%E6%95%B4%E6%95%B0">整数</a></li>
<li><a href="#%E6%B5%AE%E7%82%B9%E7%B1%BB%E5%9E%8B">浮点类型</a></li>
</ul>
</li>
<li><a href="#string">String</a></li>
<li><a href="#const">const</a></li>
</ul>
</li>
<li><a href="#%E5%A4%8D%E5%90%88%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B">复合数据类型</a><ul>
<li><a href="#%E6%95%B0%E7%BB%84">数组</a></li>
<li><a href="#slice">slice</a></li>
<li><a href="#map">map</a></li>
<li><a href="#%E7%BB%93%E6%9E%84%E4%BD%93">结构体</a></li>
</ul>
</li>
</ul>
<h1 id="基本数据"><a href="#基本数据" class="headerlink" title="基本数据"></a>基本数据</h1><h2 id="布尔"><a href="#布尔" class="headerlink" title="布尔"></a>布尔</h2><p>布尔类型，表示真与假。true|false</p>
<h2 id="整型-浮点数"><a href="#整型-浮点数" class="headerlink" title="整型/浮点数"></a>整型/浮点数</h2><p>数值类型，分为整形和浮点类型，下面列举的是类型，以及读数的区间。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">uint8</span>       the set of all unsigned  <span class="number">8</span>-bit integers (<span class="number">0</span> to <span class="number">255</span>)</span><br><span class="line"><span class="keyword">uint16</span>      the set of all unsigned <span class="number">16</span>-bit integers (<span class="number">0</span> to <span class="number">65535</span>)</span><br><span class="line"><span class="keyword">uint32</span>      the set of all unsigned <span class="number">32</span>-bit integers (<span class="number">0</span> to <span class="number">4294967295</span>)</span><br><span class="line"><span class="keyword">uint64</span>      the set of all unsigned <span class="number">64</span>-bit integers (<span class="number">0</span> to <span class="number">18446744073709551615</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">int8</span>        the set of all signed  <span class="number">8</span>-bit integers (<span class="number">-128</span> to <span class="number">127</span>)</span><br><span class="line"><span class="keyword">int16</span>       the set of all signed <span class="number">16</span>-bit integers (<span class="number">-32768</span> to <span class="number">32767</span>)</span><br><span class="line"><span class="keyword">int32</span>       the set of all signed <span class="number">32</span>-bit integers (<span class="number">-2147483648</span> to <span class="number">2147483647</span>)</span><br><span class="line"><span class="keyword">int64</span>       the set of all signed <span class="number">64</span>-bit integers (<span class="number">-9223372036854775808</span> to <span class="number">9223372036854775807</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">byte</span>        alias <span class="keyword">for</span> <span class="keyword">uint8</span></span><br><span class="line"><span class="keyword">rune</span>        alias <span class="keyword">for</span> <span class="keyword">int32</span> </span><br></pre></td></tr></table></figure>

<p>整数类型按照字节数来分类，有8位、16位、32位、64位。每个数字的区间范围、内存空间都不一样。</p>
<p>int，uint会按照cpu字节大小最终是32位或者64位。Unicode.rune和int32等价，byte和uint8等价。</p>
<p>unsafe包里面提供的uintptr，不会规定内存的size，但是能容纳从c语言传递过来的内存指针。</p>
<h3 id="整数"><a href="#整数" class="headerlink" title="整数"></a>整数</h3><p>最高位使用了反码方式来表示。拿8位来举例子。他的取值范围是(-128 to 127)</p>
<p>-128= 二进制 1111 1111</p>
<p>127= 二进制 0111 1111</p>
<p>对有符号数字做位操作时，向右移将会自动补上符号位，向左移符号位不会受到影响。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">    <span class="keyword">var</span> a <span class="keyword">int8</span></span><br><span class="line">    a = <span class="number">-1</span></span><br><span class="line">    fmt.Printf(<span class="string">&quot;%08b\n&quot;</span>, a)</span><br><span class="line">    a = a &gt;&gt; <span class="number">2</span></span><br><span class="line">    fmt.Printf(<span class="string">&quot;%08b\n&quot;</span>, a)</span><br><span class="line">    a = a &lt;&lt; <span class="number">3</span></span><br><span class="line">    fmt.Printf(<span class="string">&quot;%08b\n&quot;</span>, a)</span><br><span class="line">    </span><br><span class="line">math.MinInt8</span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">-0000001</span><br><span class="line">-0000001</span><br><span class="line">-0001000</span><br><span class="line">``</span><br><span class="line"></span><br><span class="line">这个特性需要注意，一般在操作位的时候，我们都偏向使用无符号的数字来处理。</span><br><span class="line"></span><br><span class="line">在处理循环的时候，最好推荐使用有符号的变量来处理。防止程序出现问题。</span><br><span class="line"></span><br><span class="line"><span class="comment">### 无符号</span></span><br><span class="line"></span><br><span class="line">将会把全部的bit位当成数值来计算。在做位操作时，可以当成数组来理解。</span><br><span class="line"></span><br><span class="line">整数类型的运算优先级（行里面是级别相等，从上往下的列，级别是依次降低）：</span><br><span class="line"></span><br><span class="line">```go</span><br><span class="line">* / % &lt;&lt; &gt;&gt; &amp; &amp;^</span><br><span class="line">+ - | ^</span><br><span class="line">== != &lt; &lt;= &gt; &gt;=</span><br><span class="line">&amp;&amp;</span><br><span class="line">||</span><br></pre></td></tr></table></figure>

<h3 id="浮点类型"><a href="#浮点类型" class="headerlink" title="浮点类型"></a>浮点类型</h3><figure class="highlight golang"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="keyword">float32</span>     the set of all IEEE<span class="number">-754</span> <span class="number">32</span>-bit floating-point numbers</span><br><span class="line"><span class="keyword">float64</span>     the set of all IEEE<span class="number">-754</span> <span class="number">64</span>-bit floating-point numbers</span><br><span class="line"></span><br><span class="line"><span class="comment">// 复数</span></span><br><span class="line"><span class="keyword">complex64</span>   the set of all <span class="built_in">complex</span> numbers with <span class="keyword">float32</span> <span class="built_in">real</span> and imaginary parts</span><br><span class="line"><span class="keyword">complex128</span>  the set of all <span class="built_in">complex</span> numbers with <span class="keyword">float64</span> <span class="built_in">real</span> and imaginary parts</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>提供了 float32 float64 两种。IEEE 754标准。</p>
<p>所有极限值被定义在math包中。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">math.MaxFloat32</span><br></pre></td></tr></table></figure>

<p>float32 大约能理解成6个十进制的精度；float64能到15个十进制精度。</p>
<h2 id="String"><a href="#String" class="headerlink" title="String"></a>String</h2><p>string存储了一系列的bytes，string的字节数是就是字符串的长度，而且不可能为负数。当创建了字符串之后，将不会发生改变。可以使用内建函数len取得字符串的长度。可以通过下标方式取得字符串的数值。</p>
<p>可以通过操作，可以直接分离出内容</p>
<figure class="highlight golang"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">str := <span class="string">&quot;0123456&quot;</span></span><br><span class="line">fmt.Println(str[<span class="number">0</span>:<span class="number">3</span>]) <span class="comment">// 012</span></span><br><span class="line">fmt.Println(str[<span class="number">3</span>:])  <span class="comment">// 3456</span></span><br><span class="line">fmt.Println(str[:<span class="number">3</span>])  <span class="comment">// 012</span></span><br></pre></td></tr></table></figure>

<p>不允许对字符串中间的内容做任何修改。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.\main.<span class="keyword">go</span>:<span class="number">24</span>:<span class="number">9</span>: cannot assign to str[<span class="number">2</span>]</span><br></pre></td></tr></table></figure>

<p>转移方式：</p>
<p>\x11ff 十六进制<br>\o1188 八进制</p>
<p>原生字符串，一般用于制作正则表达式。使用反引号。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> GoUsage=<span class="string">`Go is a tool for managing xxx</span></span><br><span class="line"><span class="string">xxx... `</span></span><br></pre></td></tr></table></figure>

<p>unicode字符集，参考主页：<a target="_blank" rel="noopener" href="http://unicode.org/">http://unicode.org</a></p>
<p>golang使用的是utf32或者UCS-4，每个码点占用32bit。</p>
<p>utf-8</p>
<p>ascii部分是使用1个byte，常用字使用2或3个字符来表示。</p>
<p>解析的时候，读取高位来判断是采取几个字节（二进制）来加载。</p>
<p>高位为0，就是ascii，使用1个byte</p>
<p>0xxxxxxx</p>
<p>高位为110，需要使用2个byte</p>
<p>110xxxxx 10xxxxxx</p>
<p>高位为1110，需要使用3个byte</p>
<p>1110xxxx 10xxxxxx 10xxxxxx</p>
<p>高位为11110，需要使用4个byte</p>
<p>11110xxx 10xxxxxx 10xxxxxx 10xxxxxx</p>
<p>这样能完全兼容ascii码，而且能支持字符的压缩。</p>
<p>unicode/utf8包中，RuneCountInString能量出来utf8字符长度。</p>
<p>string相关的包 bytes,strings,strconv,unicode</p>
<p>strings包，主要提供查找、替换、比较、阶段、拆分和合并功能；</p>
<p>bytes包，用于处理[]byte的库，类似于strings。由于string是不能修改的，所以一般加工字符串的时候，都通过转换成[]byte来做处理。</p>
<p>string和[]byte的转换。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">bytes := []<span class="keyword">byte</span>(<span class="string">&quot;I am byte array !&quot;</span>)</span><br><span class="line">str := <span class="keyword">string</span>(bytes)</span><br></pre></td></tr></table></figure>

<p>strconv包，用于将布尔，整型，浮点与string之间做转换；<br>unicode包，用于处理utf8相关操作。</p>
<h2 id="const"><a href="#const" class="headerlink" title="const"></a>const</h2><p>测试实例</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> learngotest</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> (</span><br><span class="line">    <span class="string">&quot;fmt&quot;</span></span><br><span class="line">    <span class="string">&quot;testing&quot;</span></span><br><span class="line">)</span><br><span class="line"></span><br><span class="line"><span class="keyword">type</span> Priority <span class="keyword">int</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> (</span><br><span class="line">    LOG_EMERG Priority = <span class="literal">iota</span></span><br><span class="line">    LOG_ALERT</span><br><span class="line">)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">TestLogiota</span><span class="params">(t *testing.T)</span></span> &#123;</span><br><span class="line">    fmt.Println(LOG_EMERG)</span><br><span class="line">    fmt.Println(LOG_ALERT)</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> (</span><br><span class="line">    mutexLocked = <span class="number">1</span> &lt;&lt; <span class="literal">iota</span> <span class="comment">// mutex is locked</span></span><br><span class="line">    mutexWoken</span><br><span class="line">    mutexStarving</span><br><span class="line">    mutexWaiterShift      = <span class="literal">iota</span></span><br><span class="line">    starvationThresholdNs = <span class="number">1e6</span></span><br><span class="line">)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">TestLockiota</span><span class="params">(t *testing.T)</span></span> &#123;</span><br><span class="line">    fmt.Println(mutexLocked)</span><br><span class="line">    fmt.Println(mutexWoken)</span><br><span class="line">    fmt.Println(mutexStarving)</span><br><span class="line">    fmt.Println(mutexWaiterShift) <span class="comment">// 3</span></span><br><span class="line">    fmt.Println(starvationThresholdNs)</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> (</span><br><span class="line">    bit0, mask0 = <span class="number">1</span> &lt;&lt; <span class="literal">iota</span>, <span class="number">1</span>&lt;&lt;<span class="literal">iota</span> - <span class="number">1</span></span><br><span class="line">    bit1, mask1</span><br><span class="line">    _, _</span><br><span class="line">    bit3, mask3</span><br><span class="line">)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">TestBitiota</span><span class="params">(t *testing.T)</span></span> &#123;</span><br><span class="line">    fmt.Println(bit0, mask0) <span class="comment">// 1,0</span></span><br><span class="line">    fmt.Println(bit1, mask1) <span class="comment">// 2,1</span></span><br><span class="line">    fmt.Println(bit3, mask3) <span class="comment">// 8,7</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h1 id="复合数据类型"><a href="#复合数据类型" class="headerlink" title="复合数据类型"></a>复合数据类型</h1><h2 id="数组"><a href="#数组" class="headerlink" title="数组"></a>数组</h2><p>数组一般都是指定长度的某种类型 。由于长度无法变化，其实很少使用到。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> a[<span class="number">3</span>] <span class="keyword">int</span></span><br><span class="line"><span class="keyword">var</span> b [<span class="number">3</span>]<span class="keyword">int</span> = [<span class="number">3</span>]<span class="keyword">int</span>&#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>&#125; <span class="comment">// 初始化</span></span><br><span class="line">c := [...]<span class="keyword">int</span>&#123;<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>&#125;<span class="comment">//简略方式</span></span><br><span class="line">r := [...]<span class="keyword">int</span> &#123;<span class="number">99</span>:<span class="number">-1</span>&#125; <span class="comment">// 初始化了100个元素，100号位置写-1，其他全部都写0</span></span><br></pre></td></tr></table></figure>

<p>数组能直接做==的检测判断。</p>
<p>在调用函数的时候，将会赋值给函数的内部变量，如果参数使用了数组，将会存在内存拷贝。如果传递大的数组，将会有性能消耗。而且在修改数组内容时，也是在复制的数组中修改。如果想减少消耗，并且支持同步修改，还是需要使用数组指针方式来传递。</p>
<h2 id="slice"><a href="#slice" class="headerlink" title="slice"></a>slice</h2><p>切片是可变长的数组。每个元素都是相同类型。它包含了指针、长度和容量。指针是指向自己持有的slice的第一个元素，不一定是真实的数组中的第一个。长度，就是当前slice的长度。容积是全部长度。slice可以通过切片方法，分离出子串。其实本质上，他们还是指向同一个数组的。只是由于他们的指针位置不同，而体现出来不一样。</p>
<p>切片的方法<code>a[n:m]</code>将会取出<code>[n,m)</code>之间的元素出来，产生新的slice。<br>注意数字就是使用的下表，<code>从0开始</code>。<br>如果n没有填写，默认意思是0。<br>m没有填写，默认就是切片的长度。<br>常见用法：<br><code>a[:]</code>获取全部内容。<br><code>a[:0]</code>清理掉全部的成员=<code>[0,0)</code>；<br><code>s = s[:len(s)-1]</code>抓取最后一个元素；<br><code>s = s[len(s)-1:]</code>删除最后一个元素；</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">make</span>([]T,<span class="built_in">len</span>,[<span class="built_in">cap</span>])</span><br><span class="line"></span><br><span class="line"><span class="comment">// 测试</span></span><br></pre></td></tr></table></figure>

<p>append函数为slice追加内容。如果cap足够，那就直接添加到尾部，否则将重新创数组，将老数组copy进去，将新的内容添加到数组尾部。append都是返回一个新的数组出来，而不会去直接修改老数组。</p>
<p>slice类似这样的数据结构：</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">type</span> IntSlice <span class="keyword">struct</span> &#123;</span><br><span class="line">    ptr *<span class="keyword">int</span></span><br><span class="line">    <span class="built_in">len</span>,<span class="built_in">cap</span> <span class="keyword">int</span> </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>在使用 slice 的时候，需要注意底层存在一个数组。如果能复用，将会大大的提高运行效率。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</span><br><span class="line">    <span class="keyword">var</span> s []<span class="keyword">int</span></span><br><span class="line">    s = <span class="built_in">make</span>([]<span class="keyword">int</span>, <span class="number">0</span>)</span><br><span class="line">    <span class="keyword">for</span> i := <span class="number">0</span>; i &lt; <span class="number">10</span>; i++ &#123;</span><br><span class="line">        s = <span class="built_in">append</span>(s, i)</span><br><span class="line">    &#125;</span><br><span class="line">    fmt.Printf(<span class="string">&quot;1 %#v\n&quot;</span>, s)</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 去掉头</span></span><br><span class="line">    s = s[<span class="number">1</span>:]</span><br><span class="line">    fmt.Println(s)</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 取出第一个</span></span><br><span class="line">    s = s[<span class="number">0</span>:<span class="number">1</span>]</span><br><span class="line">    fmt.Printf(<span class="string">&quot;2 %#v\n&quot;</span>, s)</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 清空</span></span><br><span class="line">    s = s[:<span class="number">0</span>]</span><br><span class="line">    fmt.Printf(<span class="string">&quot;3 %#v\n&quot;</span>, s)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">for</span> i := <span class="number">0</span>; i &lt; <span class="number">10</span>; i++ &#123;</span><br><span class="line">        s = <span class="built_in">append</span>(s, i)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 最后一个元素</span></span><br><span class="line">    s = s[<span class="built_in">len</span>(s)<span class="number">-1</span>:]</span><br><span class="line">    fmt.Printf(<span class="string">&quot;4 %#v\n&quot;</span>, s)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>需要做一次内存拷贝。如果不在乎顺序，可以直接将最后位置的元素，直接赋值掉指定位置的元素，删除slice最后的元素。</p>
<p>在stackoverflow里面的建议是直接使用连接两个拆分的slice，这样反而会比较高效。</p>
<p><a target="_blank" rel="noopener" href="https://stackoverflow.com/questions/37334119/how-to-delete-an-element-from-a-slice-in-golang">原文地址</a></p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">remove</span><span class="params">(slice []<span class="keyword">int</span>, s <span class="keyword">int</span>)</span> []<span class="title">int</span></span> &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="built_in">append</span>(slice[:s], slice[s+<span class="number">1</span>:]...)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>slice在循环的时候，删除一个元素<code>golang slice delete while iterating</code></p>
<p>2018-11-13<a target="_blank" rel="noopener" href="https://studygolang.com/articles/16223">golang slice遍历删除-go语言中文网</a></p>
<p>2016-07-25<a target="_blank" rel="noopener" href="https://www.pauladamsmith.com/blog/2016/07/go-modify-slice-iteration.html">Modifying a Go slice in-place during iteration </a></p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> x = []<span class="keyword">int</span>&#123;<span class="number">90</span>, <span class="number">15</span>, <span class="number">81</span>, <span class="number">87</span>, <span class="number">47</span>, <span class="number">59</span>, <span class="number">81</span>, <span class="number">18</span>, <span class="number">25</span>, <span class="number">40</span>, <span class="number">56</span>, <span class="number">8</span>&#125;</span><br><span class="line"></span><br><span class="line">i := <span class="number">0</span></span><br><span class="line">l := <span class="built_in">len</span>(x)</span><br><span class="line"><span class="keyword">for</span> i &lt; l &#123;</span><br><span class="line">    <span class="keyword">if</span> x[i] % <span class="number">2</span> != <span class="number">0</span> &#123;</span><br><span class="line">        x = <span class="built_in">append</span>(x[:i], x[i+<span class="number">1</span>:]...)</span><br><span class="line">        l--</span><br><span class="line">    &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">        i++</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line">x = x[:i]</span><br><span class="line"></span><br><span class="line">fmt.Println(x)</span><br><span class="line"><span class="comment">// [90 18 40 56 8]</span></span><br></pre></td></tr></table></figure>

<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> main</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> <span class="string">&quot;fmt&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/*slice 遍历删除示例*/</span></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</span><br><span class="line">    <span class="comment">//定义一个数字切片</span></span><br><span class="line">    ageList := []<span class="keyword">int</span>&#123;<span class="number">1</span>, <span class="number">3</span>, <span class="number">7</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">2</span>, <span class="number">5</span>&#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//遍历删除6以下的</span></span><br><span class="line">    <span class="keyword">for</span> i := <span class="number">0</span>; i &lt; <span class="built_in">len</span>(ageList); &#123;</span><br><span class="line">        <span class="keyword">if</span> ageList[i] &lt; <span class="number">6</span> &#123;</span><br><span class="line">            ageList = <span class="built_in">append</span>(ageList[:i], ageList[i+<span class="number">1</span>:]...)</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            i++</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    fmt.Printf(<span class="string">&quot;after del:%v&quot;</span>, ageList)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>输出 after del:[7 7 8]</p>
<p><a target="_blank" rel="noopener" href="https://stackoverflow.com/questions/20545743/how-to-remove-items-from-a-slice-while-ranging-over-it">stackoverflow中的例子</a></p>
<p>获取高赞的处理方法，第一遍是将全部有用节点排列到<code>&lt;i</code>的数组里面，<code>[i,j)</code>之间的内存都做一次强制的设置成空。<code>s = s[:i]</code>就是将slice区域重置。</p>
<figure class="highlight golang"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">i := <span class="number">0</span> <span class="comment">// output index</span></span><br><span class="line"><span class="keyword">for</span> _, x := <span class="keyword">range</span> s &#123;</span><br><span class="line">    <span class="keyword">if</span> isValid(x) &#123;</span><br><span class="line">        <span class="comment">// copy and increment index</span></span><br><span class="line">        s[i] = x</span><br><span class="line">        i++</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// Prevent memory leak by erasing truncated values </span></span><br><span class="line"><span class="comment">// (not needed if values don&#x27;t contain pointers, directly or indirectly)</span></span><br><span class="line"><span class="keyword">for</span> j := i; j &lt; <span class="built_in">len</span>(s); j++ &#123;</span><br><span class="line">    s[j] = <span class="literal">nil</span></span><br><span class="line">&#125;</span><br><span class="line">s = s[:i]</span><br></pre></td></tr></table></figure>

<p>注意，这将在底层数组中的索引i之后保留旧值，因此如果值是或包含指针，这将泄漏内存，直到片本身被垃圾收集。您可以通过将所有值设置为nil或从i到切片结束的零值来解决此问题，然后再截断切片。这个警告适用于说第二步骤需要小心。</p>
<h2 id="map"><a href="#map" class="headerlink" title="map"></a>map</h2><p>key/value方式无序的集合。golang中的map其实就是哈希表。其中key的类型需要支持==比较运算符。浮点型最好不好当成key。</p>
<p>创建map的方法</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">ages :=<span class="built_in">make</span>(<span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">int</span>)</span><br><span class="line">ages := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">int</span> &#123;</span><br><span class="line">    <span class="string">&quot;alice&quot;</span> : <span class="number">31</span>,</span><br><span class="line">    <span class="string">&quot;Charlie&quot;</span> : <span class="number">34</span>,</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>map的元素可以通过key下标来访问</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ages[<span class="string">&quot;alice&quot;</span>]=<span class="number">32</span></span><br><span class="line">fmt.Println(ages[<span class="string">&quot;alice&quot;</span>])</span><br></pre></td></tr></table></figure>

<p>通过delete对map中的元素删除，即使不存在也能删除。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">delete</span>(ages,<span class="string">&quot;alice&quot;</span>)</span><br></pre></td></tr></table></figure>

<p>在循环map的时候，删除keys是否安全。<code>Is it safe to remove selected keys from map within a range loop?</code></p>
<p><a target="_blank" rel="noopener" href="https://stackoverflow.com/questions/23229975/is-it-safe-to-remove-selected-keys-from-map-within-a-range-loop">stackoverflow实例map在遍历的时候删除</a></p>
<p><a target="_blank" rel="noopener" href="https://golang.org/doc/effective_go#for">effective_go</a></p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> key := <span class="keyword">range</span> m &#123;</span><br><span class="line">    <span class="keyword">if</span> key.expired() &#123;</span><br><span class="line">        <span class="built_in">delete</span>(m, key)</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>也能直接对不存在的元素直接做操作</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ages[<span class="string">&quot;bob&quot;</span>] = ages[<span class="string">&quot;bob&quot;</span>]+<span class="number">1</span></span><br></pre></td></tr></table></figure>

<p>系统会自动初始化key为bob的元素并且返回0</p>
<p>map中的元素不是变量，所以无法取得地址。原因也是由于随着元素的删减，可能内存空间有放大，或者缩小。所以取得的内存地址可能失效。</p>
<p>循环方式是</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> name,age := <span class="keyword">range</span> ages &#123;</span><br><span class="line">    fmt.Printf(<span class="string">&quot;%s\t%d\n&quot;</span>,name,age)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>由于是hash所以遍历的顺序是不固定的。map变量定义出来之后都是nil值。可以通过make语句来创建初始化。</p>
<p>如需要检查一个元素是否有初始化，可以通过</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">age, ok := ages[<span class="string">&quot;bob&quot;</span>]</span><br><span class="line"><span class="keyword">if</span> !ok &#123;</span><br><span class="line">  <span class="comment">// 不存在元素。</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>map容器不能直接做比较操作。</p>
<p>go语言没有提供set类型，可以使用map来代替。</p>
<h2 id="结构体"><a href="#结构体" class="headerlink" title="结构体"></a>结构体</h2><p>结构体里面可以定义0-n个成员。</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">type</span> T <span class="keyword">struct</span> &#123;</span><br><span class="line">    a,b <span class="keyword">int</span></span><br><span class="line">&#125;</span><br><span class="line">val := &amp;T&#123;a:<span class="number">1</span>,b:<span class="number">2</span>&#125;</span><br></pre></td></tr></table></figure>

<p>如果函数需要修改结构体内容，出于对效率的考虑，一般都是使用结构体的引用作为参数来传递。</p>
<p>结构体的嵌套</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">type</span> Point <span class="keyword">struct</span> &#123;</span><br><span class="line">    X,Y <span class="keyword">int</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">type</span> Circle <span class="keyword">struct</span> &#123;</span><br><span class="line">    Center Point</span><br><span class="line">    Radius <span class="keyword">int</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">type</span> Wheel <span class="keyword">struct</span> &#123;</span><br><span class="line">    Circle Circle</span><br><span class="line">    Spokes <span class="keyword">int</span>    <span class="comment">// 辐条</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">var</span> w Wheel</span><br><span class="line">w.Circle.Center.X = <span class="number">8</span></span><br></pre></td></tr></table></figure>

<p>go语言中能再struct中定义匿名的成员，这样就直接将其他的struct直接嵌入到了自己的结构体</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">type</span> Circle <span class="keyword">struct</span> &#123;</span><br><span class="line">    Point</span><br><span class="line">    Radius <span class="keyword">int</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">type</span> Wheel <span class="keyword">struct</span> &#123;</span><br><span class="line">    Circle</span><br><span class="line">    Spokes <span class="keyword">int</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">var</span> w Wheel</span><br><span class="line">w.X = <span class="number">9</span></span><br></pre></td></tr></table></figure>

<p>struct可以通过</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">fmt.Printf(<span class="string">&quot;%#v\n&quot;</span>,w)</span><br></pre></td></tr></table></figure>

<p>输出信息。</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/2021/07/28/2020/2020-11-03-go[2]-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B/" data-id="ckrn3an6y000f20xwfuyu793z" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/golang/" rel="tag">golang</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/type/" rel="tag">type</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2021/07/28/2020/2020-11-04-learn_git/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          git学习
        
      </div>
    </a>
  
  
    <a href="/2021/07/28/2020/2020-11-03-go%5B1%5D-%E7%A8%8B%E5%BA%8F%E7%BB%93%E6%9E%84/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">go[1]-程序结构</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/3D/" rel="tag">3D</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/AI/" rel="tag">AI</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/C/" rel="tag">C++</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Game/" rel="tag">Game</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Go/" rel="tag">Go</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Linux/" rel="tag">Linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Math/" rel="tag">Math</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Server/" rel="tag">Server</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Unreal-Engine4/" rel="tag">Unreal Engine4</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/" rel="tag">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/golang/" rel="tag">golang</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/guitar/" rel="tag">guitar</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/node-js/" rel="tag">node.js</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/" rel="tag">protobuf</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/" rel="tag">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/recast/" rel="tag">recast</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/redis/" rel="tag">redis</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/type/" rel="tag">type</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vscode/" rel="tag">vscode</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%BF%90%E7%BB%B4/" rel="tag">运维</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/3D/" style="font-size: 10px;">3D</a> <a href="/tags/AI/" style="font-size: 11.67px;">AI</a> <a href="/tags/C/" style="font-size: 15px;">C++</a> <a href="/tags/Game/" style="font-size: 18.33px;">Game</a> <a href="/tags/Go/" style="font-size: 13.33px;">Go</a> <a href="/tags/Linux/" style="font-size: 13.33px;">Linux</a> <a href="/tags/Math/" style="font-size: 11.67px;">Math</a> <a href="/tags/Server/" style="font-size: 16.67px;">Server</a> <a href="/tags/Unreal-Engine4/" style="font-size: 10px;">Unreal Engine4</a> <a href="/tags/git/" style="font-size: 10px;">git</a> <a href="/tags/golang/" style="font-size: 20px;">golang</a> <a href="/tags/guitar/" style="font-size: 10px;">guitar</a> <a href="/tags/node-js/" style="font-size: 10px;">node.js</a> <a href="/tags/protobuf/" style="font-size: 10px;">protobuf</a> <a href="/tags/python/" style="font-size: 10px;">python</a> <a href="/tags/recast/" style="font-size: 11.67px;">recast</a> <a href="/tags/redis/" style="font-size: 10px;">redis</a> <a href="/tags/type/" style="font-size: 10px;">type</a> <a href="/tags/vscode/" style="font-size: 10px;">vscode</a> <a href="/tags/%E8%BF%90%E7%BB%B4/" style="font-size: 16.67px;">运维</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/07/">July 2021</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2021/07/28/2021/2021-07-19-etcd-learn/">go-etcd阅读笔记</a>
          </li>
        
          <li>
            <a href="/2021/07/28/2021/2021-06-22-go-ethereum-learn/">go-ethereum阅读笔记</a>
          </li>
        
          <li>
            <a href="/2021/07/28/2021/2021-06-21-server%E6%B5%8B%E8%AF%95%E5%B7%A5%E5%85%B7/">server测试工具</a>
          </li>
        
          <li>
            <a href="/2021/07/28/2021/2021-06-09-pprof-doc/">go-pprof</a>
          </li>
        
          <li>
            <a href="/2021/07/28/2021/2021-04-19-c++-metaprogramming/">c++metaprogramming</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2021 Abel Sean<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">

  
<script src="/fancybox/jquery.fancybox.pack.js"></script>




<script src="/js/script.js"></script>




  </div>
</body>
</html>